package com.manong.web.common;

import com.manong.exception.BusinessExp;
import com.manong.util.JsonResult;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 自己的异常BusinessExp
 * 系统的异常RuntimeException
 */

@ControllerAdvice
public class CommonController {
    @ExceptionHandler(BusinessExp.class)
    @ResponseBody
    public JsonResult handle(BusinessExp e) {
        e.printStackTrace();
        return JsonResult.fail(e.getMessage());
    }
}
